#include "game.h"
#include "boardviewer.h"
#include "player.h"
void Game::play()
{
    bool more_moves;
    viewer_->draw(board_);
    do{
        int r, c;
        more_moves = false;
        //black player
        if(board_.get_possible_move(Black, r, c)){
            more_moves = true;
            black_->get_move(board_, r, c);
            board_.move(Black, r, c);
            viewer_->draw(board_);
        }
        else{
            black_->skip_move(board_);
        }
        //white player
        if(board_.get_possible_move(White, r, c)){
            more_moves = true;
            white_->get_move(board_, r, c);
            board_.move(White, r, c);
            viewer_->draw(board_);
        }
        else{
            white_->skip_move(board_);
        }
    }while(more_moves);
        
    if(board_.score(White) > board_.score(Black)){
        white_->win();
        black_->lose();
    }
    else if(board_.score(Black) > board_.score(White)){
        black_->win();
        white_->lose();
    }
    else{
        black_->tie();
        white_->tie();
    }
}

        
            
        
